#include <iostream>
#include <list>

using namespace std;

typedef int dataType;

typedef struct nodeType {
	dataType data;
	struct nodeType* next;
}Node;

class linkedList
{
private:
	Node* head;
	int   len_;
public:
	linkedList();
	~linkedList();
	int getLenth();
	bool isEmpty();
	void createLinkedList(int _size);
	void printLinkedList();
	dataType getValue(int _index);
	Node* findNode(dataType _data);
	void insertNode(Node* _src, int _dst, int _size);
	void insertHead(Node* _src, int _size);
	void insertEnd(Node* _src, int _size);
	void deleteNode(Node* _node);
	void deleteAll();

};

linkedList::linkedList()
{
	head = new Node;
	head->data = 0;
	head->next = NULL;
}

linkedList::~linkedList()
{
	Node* temp;
	while (head->next != NULL)
	{
		temp = head;
		head = head->next;
		delete temp;
	}
	delete head;
}

int linkedList::getLenth()
{
	return len_;
}

bool linkedList::isEmpty()
{
	if (head->next == NULL)
	{
		return true;
	}
	else
		return false;
}

dataType linkedList::getValue(int _index)
{
	int count = 0;
	Node* temp = head;
	while (count < _index)
	{
		temp->next = temp;
	}
	return temp->data;
}

void linkedList:: printLinkedList()
{
	int count = 0;
	while (head->next != NULL)
	{
		count++;
		cout << "第" << count << "个节点的数据为： " << head->data << endl;
	}
}

void linkedList::createLinkedList(int _size)
{
	Node *tempNode, *newNode;
	tempNode = head;
	if (_size < 0)
	{
		cout << "链表大小输入错误， 请重新输入" << endl;
	}
	else
	{
		for (; len_ < _size; len_++)
		{
			cout << "请输入第" << len_++ << "个节点的数据: ";
			newNode = new Node;
			cin >> newNode->data;
			newNode->next = NULL;
			tempNode->next = newNode;
			tempNode = newNode;
		}
	}
}

Node* linkedList::findNode(dataType _data)
{
	Node* p = head;
	if (p->next == NULL)
		cout << "当前链表为空" << endl;
	else
	{
		while (p->next != NULL)
		{
			p = p->next;
			if (p->data == _data)
				return p;
		}
		return NULL;
	}
}

void linkedList::insertNode(Node* _src, int _dst, int _size)
{
	Node *pleft, *pnew, *pright;
	pleft = head;
	for (int i = 0; i < _dst; i++)
		pleft = pleft->next;
	pleft->next = pright;

	for (int i = 0; i < _size; i++)
	{
		if (_src->next == NULL)
		{
			return;
		}
		else
		{
			pnew = new Node;
			pnew->data = _src -> data;
			_src = _src -> next;
			pleft->next = pnew;
			pleft = pnew;
			len_++;
		}
	}
	pleft->next = pright;
}

void linkedList::insertHead(Node* _src, int _size)
{
	insertNode(_src, 0, _size);
}

void linkedList::insertEnd(Node* _src, int _size)
{
	insertNode(_src, len_++, _size);
}

void linkedList::deleteNode(Node* _node)
{
	Node* pleft = head;
	while (pleft -> next != NULL)
	{
		if (pleft -> next  = _node)
		{
			delete pleft->next;
			pleft->next = _node->next;
		}
	}
}

void linkedList::deleteAll()
{
	Node* temp;
	while (head->next != NULL)
	{
		temp = head;
		head = head->next;
		delete temp;
	}
}





int main(int argc, char** argv)
{
	list<int> list_;
	return 0;
}